<template>
  <el-cascader v-model="value" clearable filterable :options="treeData" :props="{ label: 'label', value: 'id' }" />
</template>

<script setup>
import { postRequest } from "@/api/mains";

const props = defineProps({
  datas: {
    type: Object,
    default: () => {
      return {};
    }
  },
  url: {
    type: String,
    default: () => {
      return "";
    }
  },
  placeholder: {
    type: String,
    default: () => {
      return "请选择";
    }
  }
});

const value = ref();
const treeData = ref();

defineExpose({});

onMounted(async () => {
  if (props.url != "") {
    const { datas } = await postRequest(props.url);
    treeData.value = datas;
  }
});
watch(
  () => props.data,
  () => {
    //treeData.value = JSON.parse(JSON.stringify(props.data))
  },
  { deep: true, immediate: true }
);
</script>
